﻿using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace IMClient.Converters
{
    public class BooleanToAvatarVisibilityConverter: IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool boolValue)
            {
                // 判断 parameter 是否存在以及它的值
                if (parameter != null && bool.TryParse(parameter.ToString(), out bool reverse) && reverse)
                {
                    // 如果 parameter 为 true，逻辑反转
                    return boolValue ? Visibility.Collapsed : Visibility.Visible;
                }

                // 正常逻辑
                return boolValue ? Visibility.Visible : Visibility.Collapsed;
            }

            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
